import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import refresh from '@dfeidao/atom-web/url/refresh';

export default async function a003(fd: IFeidaoAiBrowserComponent) {
	// todo
	const vo = get(fd, "data-n");
	const optional_value = fd.data.node.querySelector<HTMLInputElement>('[data-id="optional_value"]');
	const ov = optional_value.value;
	const value_description = fd.data.node.querySelector<HTMLInputElement>('[data-id="value_description"]');
	const vd = value_description.value;

	console.log(vo);
	console.log(ov);
	console.log(vd);

	if (ov === "" || vd === "") {
		alert("请输入完整数据!");
	} else {
		const r = await nodejs<{ code: 0 | 1 }>('basic-data-wzz/zj-000003/s001', {
			data: {
				value_no: vo,
				proprity: 1551,
				optional_value: ov,
				value_description: vd
			}
		});
		console.log(r);
		if (r.code === 1) {
			alert("新增成功");
			refresh();
		}
	}
}
